package Sql;

import java.io.UnsupportedEncodingException;
import java.sql.*;

public class mysql1 {
    public static void main(String[] args) throws SQLException, UnsupportedEncodingException {
        Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/wang", "root", "");
        if (!conn.isClosed()) System.out.println("数据库连接成功");
        Statement statement = conn.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from table_name;");
        while (resultSet.next()) {
            System.out.println(resultSet.getString("Id") + "\t" + resultSet.getString("name") + "\t" + resultSet.getString("age") + "\t" + resultSet.getString("date"));
        }
    }
}
